clear all
cd "C:\Users\ot3\Documents\CRFertility\CensusMicrodata"


set more off

clear
quietly infix               ///
  int     year       1-4    ///
  long    serial     5-9    ///
  byte    month      10-11  ///
  double  hwtfinl    12-21  ///
  double  cpsid      22-35  ///
  byte    region     36-37  ///
  byte    statefip   38-39  ///
  byte    pernum     40-41  ///
  double  wtfinl     42-55  ///
  double  cpsidp     56-69  ///
  int     relate     70-73  ///
  byte    age        74-75  ///
  byte    sex        76-76  ///
  int     race       77-79  ///
  byte    marst      80-80  ///
  int     educ       81-83  ///
  int     frever     84-86  ///
  int     frbirthm1  87-89  ///
  int     frbirthy1  90-93  ///
  int     mhagemar1  94-97  ///
  using `"cps_00030.dat"'

replace hwtfinl   = hwtfinl   / 10000
replace wtfinl    = wtfinl    / 10000

format hwtfinl   %10.4f
format cpsid     %14.0g
format wtfinl    %14.4f
format cpsidp    %14.0g

keep if age>=44 & age<=70

recode race (100=0)(200=1), gen(black)

keep if statefip<=56 //non-combined, 99% of obs
drop if inlist(statefip, 2,15) //AK & HI 
g south=inlist(statefip, 1, 5, 12, 13,  22, 28, 37, 45, 47, 48, 51)

g cohort=year-age
keep if cohort>=1920 & cohort<=1960

replace frever=. if frever==999 //total birth not in universe

cd "C:\Users\ot3\Documents\CRFertility"

save cpsclean, replace










	